package com.ruoyi.business.shop.controller;

import com.alibaba.nacos.shaded.com.google.common.base.Strings;

import com.ruoyi.business.shop.domain.vo.LoginShop;
import com.ruoyi.business.shop.domain.vo.ShopRegister;

import com.ruoyi.business.shop.service.ShopLoginService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Objects;

/**
 * @ClassName: ShopLoginController
 * @description: $
 * @author: GCC
 * @date: 2025/2/21 17:27
 * @Version: 1.0
 */

@RestController
public class ShopLoginController {


    @Autowired
    private ShopLoginService shopLoginService;
    @PostMapping("/register")
    public AjaxResult register(@RequestBody ShopRegister shopRegister)
    {
        String msg = shopLoginService.register(shopRegister);
        return AjaxResult.success(msg) ;
    }
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginShop loginShop)
    {



        return AjaxResult.success(shopLoginService.login(loginShop.getCode(), loginShop.getMobile())) ;
    }

    @GetMapping("/getCode/{mobile}")
    public AjaxResult getCode(@PathVariable String mobile)
    {
        String msg = shopLoginService.getCode(mobile);
        return Strings.isNullOrEmpty(msg) ?  AjaxResult.success() : AjaxResult.error(msg);
    }

    @GetMapping("/login/getCode/{mobile}")
    public AjaxResult getLoginCode(@PathVariable String mobile)
    {
        String msg = shopLoginService.getLoginCode(mobile);
        return Strings.isNullOrEmpty(msg) ?  AjaxResult.success() : AjaxResult.error(msg);
    }

    @GetMapping("/pass/{id}")
    public AjaxResult pass(@PathVariable Long id)
    {
       shopLoginService.pass(id);
        return AjaxResult.success();
    }

}
